package com.novunda.platform.services;

import com.novunda.cas.push.client.response.ApprovePushResponse;
import com.novunda.cas.push.client.response.CommonResponse;
import com.novunda.platform.common.utils.UserUtils;
import com.novunda.platform.repositories.PushRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author yangg
 * @since 2016/10/13.
 */
@Service
public class PushService {

    @Autowired
    private PushRepository pushRepository;

    /**
     * 推送普通消息
     *
     * @param receiver 接收者
     * @param title    标题
     * @param content  内容
     * @return 推送结果
     */
    public CommonResponse normalPush(String receiver, String title, String content) {


        return pushRepository.normalPush(UserUtils.getUser().getLoginName(), receiver, title, content);
    }

    /**
     * 推送审批消息
     *
     * @param receiver 接收者
     * @param title    标题
     * @param content  内容
     * @return 推送结果
     */
    public ApprovePushResponse approvePush(String receiver, String title, String content) {

        return pushRepository.approvePush(UserUtils.getUser().getLoginName(), receiver, title, content);
    }

    /**
     * 发送广播消息
     * @param sender 发送者
     * @param title 标题
     * @param content 内容
     * @return 推送结果
     */
    public CommonResponse broadCast( String title, String content){
        return pushRepository.broadCast(UserUtils.getUser().getLoginName(), title, content);
    }

}
